public class DocPanelBase : Gtk.Table 
{
	protected weak Gtk.SourceBuffer source_buff = null;
	protected weak Gtk.SourceView source_view = null;
	protected Gtk.Button close_btn;
	private static bool doc_panel_mutex = false; //FIXME: ident

	public signal bool show_panel ();
	public signal bool close_panel ();
		
	public DocPanelBase (uint rows, uint columns, bool homogeneous, ref Gtk.SourceBuffer source_buff, ref Gtk.SourceView source_view)
	{
		this.resize (rows, columns);
		this.set_homogeneous (homogeneous);
		
		this.source_buff = source_buff;
		this.source_view = source_view;
		
		this.key_press_event += this.on_key_press_event;

		this.close_btn = Utils.create_small_button (
			new Gtk.Image.from_stock (Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
		);
		this.close_btn.clicked += this.close;
		this.attach (close_btn, columns - 1, columns, 0, 1, Gtk.AttachOptions.SHRINK, Gtk.AttachOptions.SHRINK, 5, 0);
		
		this.set_no_show_all (true);
	}
	
	public void show ()
	{
		if (!this.show_panel ())
		{
			this.set_no_show_all (false);
			this.show_all ();
			this.show_now ();		
		}
	}
	
	public void close ()
	{
		if (!this.close_panel ())
		{
			this.hide_all ();
		}		
	}
	
	protected virtual bool on_key_press_event (DocPanelBase sender, Gdk.EventKey event)
	{
		if (Gdk.keyval_name(event.keyval) == "Escape")
		{
			this.close ();
		}
		else if (Gdk.keyval_name(event.keyval) == "Tab")
		{
			return true;
		}
		return false;
	}
}
